<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <div
      class="outline-parent-bg border-hover-style"
      :style="{
        backgroundImage: `url(${publicUrls + 'free/style4/Auxiliaryoutlinestyle5Bg.webp'})`,
      }"
    >
      <div
        class="audio-box"
        :class="isPlay && 'audio-rotate'"
        :id="!props.info.remarks && 'audio-height'"
        v-if="props.info.audio && props.info.audio.url"
        @click="audioplay(true)"
      >
        <i class="doorIcon">&#xe688;</i>
      </div>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
      <div class="content-box">
        <p class="title-name" v-if="props.info.text">{{ props.info.text }}</p>
        <p
          class="sub-title"
          :style="{
            marginTop: props.info.remarks || props.info.value || props.info.video.url ? '10px' : '20px',
          }"
          v-if="props.info.subTitle"
        >
          {{ props.info.subTitle }}
        </p>
        <div
          class="cover"
          :class="{ cover2: !props.info.remarks, cover3: !props.info.remarks && !props.info.subTitle }"
          @click="ImgVisible = true"
          v-if="props.info.value || (props.info.video && props.info.video.url)"
        >
          <img
            class="cover-img"
            :src="urls + props.info.value + '?imageView2/3/format/webp'"
            alt=""
            v-if="props.info.value && !(props.info.video && props.info.video.url)"
          />
          <videoview @click="audioplay(false)" :info="props.info"></videoview>
        </div>
        <div class="remarks" v-if="props.info.remarks">
          <TextMax
            :data="props.info.remarks"
            :infoData="props.info"
            :title="props.info.text"
            :row="props.info.value || (props.info.video && props.info.video.url) ? (props.info.subTitle ? 2 : 3) : 7"
          ></TextMax>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free4Style5',
});
</script>
<script lang="ts" setup>
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';
import digitalShowroomIcon from '@/freeComponents/unitdigitalShowroom/style4.vue';
const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style lang="less" scoped>
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 220px linear-gradient(transparent, rgba(0, 0, 0, 0.2));
  margin: 0 80px;
}
.outline-parent-bg {
  width: 464px;
  height: 558px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  margin-right: 60px;
  margin-top: 10px;
  position: relative;
}
.audio-box {
  width: 32px;
  height: 32px;
  position: absolute;
  top: 20px;
  right: 20px;
  border-radius: 50%;
  border: 1px solid rgba(131, 176, 179, 1);
  background-color: rgba(212, 223, 219, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  .doorIcon {
    color: #83b0b3;
    font-size: 18px;
  }
}
.content-box {
  width: 342px;
  height: 426px;
  position: absolute;
  top: 52px;
  left: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.title-name {
  width: 189px;
  flex-shrink: 0;
  color: #5391a3;
  text-align: center;
  font-family: 'SourceHanSerifCN';
  font-size: 20px;
  font-style: normal;
  font-weight: 700;
  line-height: 28px; /* 140% */
}
.sub-title {
  width: 274px;
  color: #333;
  text-align: center;
  font-family: 'PingFang SC';
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 24px; /* 150% */
  opacity: 0.8;
  //   margin-top: 10px;
}
.cover2 {
  height: 225px !important;
}
.cover3 {
  margin-top: 20px !important;
}
.cover {
  width: 274px;
  height: 158px;
  flex-shrink: 0;
  background: #ddebe9;
  overflow: hidden;
  margin-top: 10px;
  .cover-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: all 0.5s;
  }
  &:hover {
    .cover-img {
      transform: scale(1.2);
    }
  }
}
.remarks {
  width: 274px;
  flex-shrink: 0;
  margin-top: 10px;
}
::v-deep .van-text-ellipsis {
  color: rgba(51, 51, 51, 0.8) !important;
  font-family: 'PingFang SC' !important;
  font-size: 16px !important;
  font-style: normal;
  font-weight: 400;
  line-height: 32px; /* 200% */
  opacity: 0.8;
}
::v-deep .van-text-ellipsis__action::before {
  color: #83b0b3 !important;
  font-family: 'PingFang SC' !important;
  font-size: 16px !important;
  font-style: normal;
  font-weight: 500;
  line-height: 32px;
  text-decoration: underline;
  text-underline-offset: 4px;
}
</style>
